import java.util.Arrays;

/**
 * @author LKQ
 * @date 2021/12/20 22:39
 * @description 排序+双指针
 */
public class Solution1 {
    public static void main(String[] args) {
        Solution1 solution = new Solution1();
        int[] houses = {1, 5, 10}, heaters = {7, 3};
        System.out.println(solution.findRadius(houses, heaters));
    }
    public int findRadius(int[] houses, int[] heaters) {
        Arrays.sort(houses);
        Arrays.sort(heaters);
        int ans = 0;
        for (int i = 0, j = 0; i < houses.length; i++) {
            int curDistance = Math.abs(houses[i] - heaters[j]);
            while (j < heaters.length - 1 && Math.abs(houses[i] - heaters[j]) >= Math.abs(houses[i] - heaters[j + 1])) {
                j++;
                curDistance = Math.min(curDistance, Math.abs(houses[i] - heaters[j]));
            }
            ans = Math.max(ans, curDistance);
        }
        return ans;
    }


}
